OrdinAide

Macintosh, Apache, Mysql et PHP (MAMP)

MAMP est un installeur combiné de Apache, Mysql et PHP pour Macintosh. Développé par living-e, il permet d'installer en quelques clics, un serveur web local sur son ordinateur, avec Apache pour le serveur web, MySQL 5 pour la base de données, phpMyAdmin pour la gestion des bases de données, PHP 4 ou 5 ou encore eAccelerator. Il est possible de choisir les ports à utiliser, le dossier root, et bien sur de configurer php.ini et httpd.conf selon les besoins (extrait de configmac.com/logiciel75.html).

Pour faire tourner en local à la fois PHP 4 et 5 et MySQL 4 et 5, suivre les conseils de http://drupal.org/node/222225, dont suit ci-dessous un résumé.

Etape 1 : installations préalables (à celle de MAMP)

  • configurer la version native du serveur de pages Web Apache qui est installé en natif (avec le système "de base" MacOS depuis MacOS X), en éditant les fichiers d'extension .conf situés dans le dossier /private/etc/apache2/
  • configurer la version de PHP 5 (en éditant le fichier php.ini)
  • faire une installation d'un serveur MySQL 4 direct (indépendant de MAMP, puisque celui intégré est MySQL 5)

Etape 2 : installations de MAMP

Etape 3 : intégrer les 2 environnements

Le but est d'obtenir une racine commune, des hotes virtuels, urls et outils système. En particulier, nous utiliserons l'application Terminal pour le MySQL de MAMP.

We'll make it so that we can keep all of our sites, no matter which enviroment they require, in a common place -- and so that no matter what we're running we will always be able type in "localhost", or and know that it will take us to our doc root (instead of having to remember to type "localhost:8888/" for MAMP:). Relatedly, doing the steps below lets us keep common server names (e.g., 'mysite.local') across environments. So now: * Change the docroot in MAMP's httpd.conf (line 368) to: DocumentRoot "/Library/WebServer/Documents" * Change the port in MAMP's preferences so that it uses port 80 instead of 8888 and add all of your virtualhosts from you native mac's Apache configuration file to MAMP's httpd.conf file. Step four: This step is optional, only useful if you want to be able to use terminal with MAMP's MySQL. The mysql.sock symlink. If you've done everything correctly (see above links), the standalone MySQL will already have a symlink for mysql.sock at /var/mysql/mysql.sock AND /tmp/mysql.sock. To get MAMP's MySQL working on the commandline we have a situation where both MySQL installs need to have a symlink that exists within /tmp/ and which points to their own respective mysql.sock files (for whatever reason MAMP doesn't seem to care about having a symlink at /var/mysql). This is bit of an annoyance since two files with the same directory cannot share the same name. At the moment I manage this just by pasting the following code into terminal when I want to be able to be able to access MAMP's MySQL with terminal.

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
sudo chown _mysql /var/mysql/mysql.sock
sudo chmod 777 /var/mysql/mysql.sock
It's an admittedly inelegant solution. I should probably make a script that does this automatically, or change all the paths within on of the MySQL installs so that it would look for a mysql-2.sock file or something like that, but it works in a pinch. :-) Fyi, though the two MySQL instances seems to be able to work concurrently, with this setup you cannot run two HTTPD (apache) instances at one time. Not a big deal in my workflow, but I thought I should mention in case anyone is wondering.